package logic.weapons;

import logic.nodes.lod.blocks.LeafBlock;

import com.jme.math.FastMath;
import com.jme.math.Vector3f;

public class WeaponFireVisibility {
	
	public static final float MIN_MOVES_AWAY_ANGLE = 90f;
	
	public static boolean isNeverVisibleTo(WeaponFire fire, Vector3f location) {
		if(isInRange(fire, location)) return false;
		
		return movesAwayFrom(fire, location);
	}
	
	public static boolean isInRange(WeaponFire fire, Vector3f location) {
		float dist = location.distance(fire.getLocalTranslation());
		return dist <= LeafBlock.particleDist;
	}
	
	public static boolean movesAwayFrom(WeaponFire fire, Vector3f location) {
		Vector3f fireDir = fire.getDirection().normalize();
		Vector3f fireToLoc = location.subtract(fire.getLocalTranslation()).normalize();
		float angle = fireDir.angleBetween(fireToLoc);
		angle *= FastMath.RAD_TO_DEG;
		return angle >= 90f;
	}
}